import { reqCategoryList, reqGetBannerList, reqGetFloor } from '@/api';

const state = {
	cateGoryList: [],
	bannerList: [],
	floor: []
};
const mutations = {
	GETCATEGORYLIST(state, data) {
		state.cateGoryList = data.splice(0, 15);
	},
	GETBANNERLIST(state, data) {
		state.bannerList = data;
	},
	GETFLOOR(state, data) {
		state.floor = data;
	}
};
const actions = {
	/**
	 *三级列表数据
	 * @param {*} param0
	 */
	async getCategoryList({ commit }) {
		let res = await reqCategoryList();
		if (res.code === 200) {
			commit('GETCATEGORYLIST', res.data);
		}
	},
	/**
	 * mock轮播图数据
	 * @param {*} param0
	 */
	async getBannerList({ commit }) {
		let res = await reqGetBannerList();
		if (res.code == 200) commit('GETBANNERLIST', res.data);
	},
	/**
	 * 获取floor数据
	 * @param {*} param0
	 */
	async getFloor({ commit }) {
		let res = await reqGetFloor();
		if (res.code == 200) {
			commit('GETFLOOR', res.data);
		}
	}
};
const getters = {};

export default {
	state,
	mutations,
	actions,
	getters
};
